﻿using IntelligentAgriculture.Contracts.Dto.Output;
using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.WebAPI.Application.Command.PregnancyCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.PregnancyCommandHandler
{
    public class PregnancyGetCommandHandler : IRequestHandler<PregnancyGetCommand, PageOutput<PregnancyOutput>>
    {
        private readonly IPregnancyService _pregnancyService;
        public PregnancyGetCommandHandler(IPregnancyService pregnancyService)
        {
             _pregnancyService = pregnancyService;
        }

        public async Task<PageOutput<PregnancyOutput>> Handle(PregnancyGetCommand request, CancellationToken cancellationToken)
        {
            var result = await _pregnancyService.GetPageOutputAsync(request.startPregnancyDate, request.endPregnancyDate, request.eartag, request.userId, request.pregnancyResult, request.parityNum, request.pageIndex, request.pageSize);
            return result;
        }
    }
}
